import dayjs from 'dayjs';
import * as nav from '@/utils/navFunc.js'
import { DecimalUtils } from '../utils/math';
export default {
	install(Vue) {
		// 全局过滤器
		let safeAreaBottom = uni.getSystemInfoSync().safeAreaInsets.bottom;
		let statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
		Vue.filter('parseTime', function(value, str = 'YYYY-MM-DD HH:mm') {
			if (value) {
				const time = dayjs(value).format(str);
				if (time === 'Invalid Date') {
					return value;
				} else {
					return dayjs(value).format(str);
				}
			} else {
				return '';
			}
		});
		// 全局混入
		Vue.mixin({
			data() {
				return {
					// 底部安全距离
					safeAreaBottom: safeAreaBottom,
					// 顶部状态栏安全距离
					statusBarHeight: statusBarHeight
				}
			},
			methods: {
				onClickLeft() {
					uni.navigateBack();
				}
			}
		})
		Vue.prototype.$navTo = nav.navTo;
		Vue.prototype.$navBack = nav.navBack;
	}
};